<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@page import="com.googlecode.contests_repo.core.users.AccessRight"%>
<%@page import="com.googlecode.contests_repo.core.users.UserManager"%>
<%@page import="com.googlecode.contests_repo.core.config.ConfigurationManager"%>
<%@page import="java.util.List"%>
<%@page import="com.googlecode.contests_repo.core.model.ResourcesUtils"%>
<%@page import="com.googlecode.contests_repo.core.model.Series"%>
<%@page import="java.io.File"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page
	import="java.util.ArrayList,com.googlecode.contests_repo.core.model.Resource"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Series list</title>
</head>
<body>
<%@include file='header.jsp'%>
	<h1>List of all available series</h1>
	<br />
	<table border=1>
		<tr>
			<th>Title</th>
			<th>About</th>
			<th>View</th>
		</tr>
		<%
		    String loggedUser = (String)session.getAttribute("username");
				    String repoPath = ConfigurationManager.getInstance().getRepoRoot();
				    List<Series> seriesList = ResourcesUtils.fetchResources(new File(repoPath));
				    if (seriesList != null)
				    {
						for (Series series : seriesList)
						{
						    if (UserManager.hasAccessRight(loggedUser, repoPath + File.separator + series.getTitle(), AccessRight.LIST))
						    {
		%>
		<tr>
			<td><%=series.getTitle()%></td>
			<td><%=series.getAbout()%></td>
			<td><a href="series.jsp?series=<%=series.getTitle()%>">details</a></td>
		</tr>
		<%
		    		}
		    	}
		    }
		%>
	</table>
	<br />
	<br />
<a href="home.jsp">Back</a>
</body>
</html>